<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class AddUniqueUUIDIndexInDelayOrderTaskTable extends AbstractMigration
{
    public function up()
    {

        $this->table('delay_order_task')
            ->addIndex(['uuid'], ['type' => 'unique', 'name' => 'idx_unique_uuid'])
            ->addColumn('step_category_id', 'integer', ['signed' => false, 'limit' => 11, 'default' => 0, 'null' => false, 'comment' => '环节id'])
            ->addColumn('episode_id', 'integer', ['signed' => false, 'limit' => 11, 'default' => 0, 'null' => false, 'comment' => '剧集id'])
            ->addColumn('step_category_confirmed', 'enum', ['values' => 'default,yes,no', 'default' => 'default', 'null' => false, 'comment' => '环节是否确认'])
            ->addColumn('manager_confirmed', 'enum', ['values' => 'default,yes,no', 'default' => 'default', 'null' => false, 'comment' => '管理人员是否确认'])
            ->addColumn('manager_confirm_user_id', 'integer', ['signed' => false, 'limit' => 11, 'default' => 0, 'null' => false, 'comment' => '确认管理人员ID'])
            ->changeColumn('type', 'enum', ['values' => 'request_delay,today_done,demand_order,downstream_delay', 'default' => 'request_delay', 'null' => false, 'comment' => '延期类型'])
            ->save();
    }

    public function down()
    {
        $this->table('delay_order_task')
            ->removeIndexByName('idx_unique_uuid')
            ->removeColumn('step_category_confirmed')
            ->removeColumn('manager_confirmed')
            ->removeColumn('step_category_id')
            ->removeColumn('episode_id')
            ->removeColumn('manager_confirm_user_id')
            ->changeColumn('type', 'enum', ['values' => 'request_delay,today_done,demand_order', 'default' => 'request_delay', 'null' => false, 'comment' => '延期类型'])
            ->save();
    }
}
